export default function base64ToPath(base64) {
  return new Promise((resolve, reject) => {
    if (typeof window === 'object' && 'document' in window) {
      base64 = base64.split(',')
      const type = base64[0].match(/:(.*?);/)[1]
      const str = atob(base64[1])
      let n = str.length
      const array = new Uint8Array(n)
      while (n--) {
        array[n] = str.charCodeAt(n)
      }
      return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], { type })))
    }
  })
}
